package org.jrill;

/**
 * An Activity on the {@link Workflow}
 * @author K.Waga
 */
public class HumanActivity extends AbstractActivity {
    private static final long serialVersionUID = 4678796266177819571L;

    /**
     * Returns whether this activity is empty or not
     * @return
     */
    public boolean isEmpty() {
       return null == this.getOwner();
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final HumanActivity other = (HumanActivity) obj;
        if (getId() != other.getId() && (getId() == null || !getId().equals(other.getId()))) {
            return false;
        }
        if (this.getVersion() != other.getVersion() && (this.getVersion() == null || !this.getVersion().equals(other.getVersion()))) {
            return false;
        }
        if ((this.getOrganization() == null) ? (other.getOrganization() != null) : !this.getOrganization().equals(other.getOrganization())) {
            return false;
        }
        if ((this.getRole() == null) ? (other.getRole() != null) : !this.getRole().equals(other.getRole())) {
            return false;
        }
        if (this.getOwner() != other.getOwner() && (this.getOwner() == null || !this.getOwner().equals(other.getOwner()))) {
            return false;
        }
        if (this.isParallel() != other.isParallel()) {
            return false;
        }
        if (this.getDueDate() != other.getDueDate() && (this.getDueDate() == null || !this.getDueDate().equals(other.getDueDate()))) {
            return false;
        }
        if (this.isProcessed() != other.isProcessed()) {
            return false;
        }
        if ((this.getNote() == null) ? (other.getNote() != null) : !this.getNote().equals(other.getNote())) {
            return false;
        }
        return true;
    }

    /**
     * {@inheritDoc }
     * @see Activity
     */
    @Override
    public int hashCode() {
        int hash = 7;
        hash = 37 * hash + (getId() != null ? getId().hashCode() : 0);
        hash = 37 * hash + (this.getVersion() != null ? this.getVersion().hashCode() : 0);
        hash = 37 * hash + (this.getOrganization() != null ? this.getOrganization().hashCode() : 0);
        hash = 37 * hash + (this.getRole() != null ? this.getRole().hashCode() : 0);
        hash = 37 * hash + (this.getOwner() != null ? this.getOwner().hashCode() : 0);
        hash = 37 * hash + (this.isParallel() ? 1 : 0);
        hash = 37 * hash + (this.getDueDate() != null ? this.getDueDate().hashCode() : 0);
        hash = 37 * hash + (this.isProcessed() ? 1 : 0);
        hash = 37 * hash + (this.getNote() != null ? this.getNote().hashCode() : 0);
        return hash;
    }

    /**
     * {@inheritDoc}
     * @see Object#toString() 
     */
    @Override
    public String toString() {
        return "Activity{" + "id=" + getId() + ", version=" + getVersion() + ", workflowId=" + (null != getWorkflow() ? getWorkflow().getId() : null) + ", organization=" + getOrganization() + ", role=" + getRole() + ", owner=" + getOwner() + ", parallel=" + isParallel() + ", dueDate=" + getDueDate() + ", processed=" + isProcessed() + ", note=" + getNote() + '}';
    }

}
